package com.hycreate.platform.modules.element;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.hycreate.platform.common.persistence.Page;
import com.hycreate.platform.common.service.CrudService;
import com.hycreate.platform.common.utils.StringUtils;
import com.hycreate.platform.common.utils.mypage.PageDemo;
import com.hycreate.platform.modules.atta.SfAttachment;
import com.hycreate.platform.modules.element.SfElement;
import com.hycreate.platform.modules.element.SfElementDao;
import com.hycreate.platform.modules.product.element.SfProductElement;

/**
 * 配件Service
 * @author hoader
 * @version 2017-01-09
 */
@Service
@Transactional(readOnly = true)
public class SfElementService extends CrudService<SfElementDao, SfElement> {
	
	/*public static void main(String[] args) {
		for(int i = 0; i < 100; i++){
			
			java.util.Random random = new java.util.Random();// 定义随机类
			int result = random.nextInt(700);
			System.out.print(result);
			System.out.print("==");
			System.out.println(result * 80 / 100);
		}
	}*/

	public SfElement get(String id) {
		return super.get(id);
	}
	
	public List<SfElement> findList(SfElement sfElement) {
		return super.findList(sfElement);
	}
	
	public Page<SfElement> findPage(Page<SfElement> page, SfElement sfElement) {
		return super.findPage(page, sfElement);
	}
	
	@Transactional(readOnly = false)
	public void save(SfElement sfElement) {
		/*if(StringUtils.isEmpty(sfElement.getNum())){
			java.util.Random random = new java.util.Random();// 定义随机类
			int result = random.nextInt(700) + 300;
			sfElement.setNum(String.valueOf(result));
		}
		if(StringUtils.isEmpty(sfElement.getSafeNum())){
			int num = Integer.parseInt(sfElement.getNum());
			num = num * 80 / 100;
			sfElement.setSafeNum(String.valueOf(num));
		}*/
		super.save(sfElement);
	}
	
	@Transactional(readOnly = false)
	public void delete(SfElement sfElement) {
		super.delete(sfElement);
	}
	
	
	public List<SfAttachment>	findElementPic(String id){
		
		return dao.findElementPic(id);
	}
	
	@Transactional(readOnly = false)
    public void batchDeletes(List delList){
    	
    	dao.batchDeletes(delList);
    }
	
	public List<SfElement>  findElement(PageDemo pd){
		return dao.findElement(pd);
	}
	
	public int  elementCount(String id){
		return dao.elementCount(id);
	}
	
	 public List<SfProductElement> DELLIST(){
		 
		 return dao.DELLIST();
	 }
	
	 @Transactional(readOnly = false)
	 public void DeletesRedundancy(List delList){
		 
		 dao.DeletesRedundancy(delList);
	 }
	 
}